﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
    using System.Net.Http;
    using System.Web.Http.Filters;

namespace XQ.RequestOfficeSupplies.WebAPI.Filter
{
    

    public class CustomExceptionFilterAttribute : ExceptionFilterAttribute
    {
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            var exception = actionExecutedContext.Exception;
            var response = actionExecutedContext.Response;
            response.Content = new StringContent($"错误信息: {exception.Message}\n堆栈跟踪: {exception.StackTrace}");
            response.StatusCode = HttpStatusCode.InternalServerError; // 或者根据错误类型设置不同的状态码
            base.OnException(actionExecutedContext);
        }
    }
}